<template>
	<view>
		<view>
			<view style="display: flex;">
				<view style="margin:20rpx 0 40rpx 100rpx;font-weight: 800;color:#0000FF;font-size: 46rpx;">巡查情况
					<view class="leaveLine"></view>
				</view>
				<button class="leaveBtn" style="margin-top:20rpx;" @click="goto()">提交</button>
			</view>
			<view style="width: 90%;margin: 0 auto;">
				<view style="color:#8F8F94;margin:20rpx">楼栋：{{leaveArrXq.buildingNo}}</view>
				<view style="color:#8F8F94;margin:20rpx">宿舍号：{{leaveArrXq.dormitoryNo}}</view>
				<view style="color:#8F8F94;margin:20rpx">巡查时间：{{leaveArrXq.createdTime | showTime}}</view>
				<view style="color:#8F8F94;margin:20rpx">卫生情况：
					<span v-if="leaveArrXq.patrolStatus==1">优秀</span>
					<span v-if="leaveArrXq.patrolStatus==2">良好</span>
					<span v-if="leaveArrXq.patrolStatus==3">差</span>
				</view>
				<view style="color:#8F8F94;margin:20rpx">备注信息：{{leaveArrXq.describeTxt}}</view>
				<view style="color:#8F8F94;margin:20rpx">
					<image style="width: 100px; height: 100px; background-color: #eeeeee;" src="leaveArrXq.patrolImg">
					</image>
				</view>
				<view style="color:#8F8F94;margin:20rpx">巡查情况登记人：{{leaveArrXq.createBy}}</view>
				<view style="margin:40rpx 20rpx 20rpx 20rpx">
					<view class="title">登记处理</view>
					<textarea class="repText2" placeholder="请输入处理结果" v-model="register"
						style="font-weight: 500;font-size: 32rpx;"></textarea>
				</view>
			</view>
			<view class="logoSty"></view>
		</view>
	</view>
</template>

<script>
	import topCom from '../component/topCom.vue'
	import bottomCom from '../component/bottom.vue'
	export default {
		data() {
			return {
				register: "",
				userName: '',
				topName: '值班巡查处理',
				ids: 0,
				leaveArrXq: {},
				actualHandler: "",
				patrolId: 0,
			}
		},
		filters: {
			showTime(value) {
				var date = new Date();
				var year = date.getFullYear();
				var month = date.getMonth() + 1;
				month = month > 0 ? month : '0' + month; //个位数前面补零
				var day = date.getDate() > 0 ? date.getDate() : '0' + date.getDate();
				return `${year}-${month}-${day}`
			}
		},
		components: {
			topCom,
			bottomCom
		},
		methods: {
			//提交按钮
			goto() {
				uni.showLoading({
					mask: true,
					title: '提交中'
				})
				this.$api.dormitory.getUpdate(this.patrolId, this.register, this.actualHandler).then(res => {
					console.log(res);
					uni.hideLoading();
					if (res.message == "操作成功") {
						uni.showToast({
							title: '提交成功！',
							icon:'success',
							duration: 3000
						});
						uni.navigateTo({
							url: `/pages/abnormal/Patrol`,
							success: res => {},
							fail: () => {},
							complete: () => {}
						});
					} else {
						uni.showToast({
							title: '提交失败！',
							duration: 2000
						});
					}
				})
			}
		},
		onLoad(option) {
			this.leaveArrXq = JSON.parse(option.str);
			this.patrolId = this.leaveArrXq.id;
			console.log(this.leaveArrXq);
		},
		onShow() {
			var that = this
			uni.getStorage({
				key: 'loginName',
				success(res) {
					that.userName = res.data
				}
			})

			this.actualHandler = uni.getStorageSync("loginName");
		},
	}
</script>

<style>
	.indexTeacher {
		margin: auto;
		margin-top: 40upx;
		width: 605upx;
		height: 72upx;
		display: flex;
		justify-content: space-between;
		background-image: url(https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/T-4.png);
		background-size: 100%;
		color: white;
		padding: 30upx 20rpx 0rpx 20rpx;
		font-size: 22rpx;
		/* opacity: 0.8; */
	}

	.indexTeacher0 {
		margin: auto;
		margin-top: 40upx;
		width: 605upx;
		height: 72upx;
		display: flex;
		justify-content: space-between;
		background-image: url(https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/T-6.png);
		background-size: 100%;
		color: white;
		padding: 30upx 20rpx 0rpx 20rpx;
		font-size: 22rpx;
		/* opacity: 0.8; */
	}

	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.leaveBtn {
		background-image: url(https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/tubiao-01.png);
		background-size: 100%;
		width: 220upx;
		height: 70upx;
		color: white;
		font-size: 32rpx;
		font-weight: 0;
		line-height: 70rpx;
	}

	.repText2 {
		border: solid 1upx #999999;
		border-radius: 20upx;
		width: 600rpx;
		height: 200upx;
		word-wrap: break-word;
		margin-top: 20rpx;
		padding: 5px;
		/* margin-left:-10rpx; */
	}
</style>
